package com.xmy.cultivate.mapper;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.xmy.cultivate.entity.RenewData;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.xmy.cultivate.entity.views.ReNewDetailForTeacher;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author min
 * @since 2022-11-29
 */
public interface RenewDataMapper extends BaseMapper<RenewData> {

    //@Select("select  count(id) as count from renew_data where school_id = #{schoolId} and teacher_id =#{teacherId} and subjects_id = #{subjectsId} and year_part_renew=#{yearPart} and quarter_num_renew = #{quarterNum} and level=#{level} and year_class_id <>9 and year_class_id is not null and type=1")
    @Select("select  count(student_id) as count from renew_data ${ew.customSqlSegment}")
    public abstract Integer getShouldCount(@Param(Constants.WRAPPER) Wrapper wrapper);

    //@Select("select  count(id) as count from renew_data where school_id = #{schoolId} and teacher_id =#{teacherId} and subjects_id = #{subjectsId} and year_part_renew=#{yearPart} and quarter_num_renew = #{quarterNum} and level=#{level} and year_class_id <>9 and year_class_id is not null and type=1 and is_renew=#{isRenew}")
    @Select("select  count(student_id) as count from renew_data ${ew.customSqlSegment}")
    public abstract Integer getAlreadyShouldCount(@Param(Constants.WRAPPER) Wrapper wrapper);


    @Select("select * from renew_data ${ew.customSqlSegment}")
    public abstract IPage<ReNewDetailForTeacher> getStudentDetailList(IPage<?> page, @Param(Constants.WRAPPER) Wrapper wrapper);

    @Select("select student_id from renew_data ${ew.customSqlSegment}")
    public abstract List<Long> getDetailToStudentIds(@Param(Constants.WRAPPER) Wrapper wrapper);

}
